import 'package:flutter/material.dart';

class GCTheme {
  static const double normalFontSize = 15;
  static const double titleFontSize = 20;
  static const double subTitleFontSize = 18;

  static final Color masterColor = Color(0xFF40A8B3);

  static final ThemeData defaultTheme = new ThemeData(
      splashColor: Colors.transparent,
      visualDensity: VisualDensity.adaptivePlatformDensity,
      highlightColor: Colors.transparent,//去除点击tabbar的过度效果
      primarySwatch: createMaterialColor(masterColor),
    scaffoldBackgroundColor: Color(0xFFF4F8FE),
    appBarTheme: AppBarTheme(
      elevation: 0,
      backgroundColor: Colors.white,
      titleTextStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 16, color: Colors.white),
    ),
    tabBarTheme: TabBarTheme(
      labelStyle: TextStyle(fontSize: 9, color: masterColor),
      unselectedLabelStyle: TextStyle(fontSize: 9, color: Color(0xFF333333)),
    ),
    textTheme: TextTheme(subtitle2: TextStyle(textBaseline: TextBaseline.alphabetic))
  );

  static MaterialColor createMaterialColor(Color color) {
    List strengths = <double>[.05];
    Map swatch = <int, Color>{};
    final int r = color.red, g = color.green, b = color.blue;

    for (int i = 1; i < 10; i++) {
      strengths.add(0.1 * i);
    }
    strengths.forEach((strength) {
      final double ds = 0.5 - strength;
      swatch[(strength * 1000).round()] = Color.fromRGBO(
        r + ((ds < 0 ? r : (255 - r)) * ds).round(),
        g + ((ds < 0 ? g : (255 - g)) * ds).round(),
        b + ((ds < 0 ? b : (255 - b)) * ds).round(),
        1,
      );
    });
    return MaterialColor(color.value, swatch);
  }
}

